<?php

include_once 'config.php';

$image = @$_POST["image"];

if($image) {
	
	if (preg_match('/^[fh]t+ps?:\/\//', $image)) {
		$image = preg_replace('/^[fh]t+ps?:\/+/',"",$image);
		$image = substr($image,strpos($image,"/"));
	}
	
	$path = $_SERVER["DOCUMENT_ROOT"].$image;
	$deleted = unlink($path);
	if($deleted) {
		header("X-Imagepicker-Delete-Status: 1");
		echo "Image deleted.";
	}else{
		echo "\nGreška. Slika \"$image\" nije obrisana.";
	}
}

?>